<?php
abstract class Jisuanqi {
	abstract function jisuan($x, $y);
}

class Jia extends Jisuanqi {
	function jisuan($x, $y) {
		return $x . "+" . $y . "=" . ($x + $y);
	}

}

class Jian extends Jisuanqi {
	function jisuan($x, $y) {
		return $x . "-" . $y . "=" . ($x - $y);
	}

}

class Cheng extends Jisuanqi {
	function jisuan($x, $y) {
		return $x . "*" . $y . "=" . ($x * $y);
	}

}

class Chu extends Jisuanqi {
	function jisuan($x, $y) {
		return $x . "/" . $y . "=" . ($x / $y);
	}

}

class Yu extends Jisuanqi {
	function jisuan($x, $y) {
		return $x . "%" . $y . "=" . ($x % $y);
	}

}

class Gongcahng {
	static function createobject($str) {
		//PHP默认是多态
		if (class_exists($str)) {
			return new $str();
		} else {
			return new Jia();
		}
	}

}

$str = Gongcahng::createobject("Cheng");
echo $str -> jisuan(7, 2);
?>